<template>
    <div class="title-wrapper">
        <el-skeleton animated :loading="loading">
            <template #template>
                <el-skeleton-item />
                <el-skeleton-item />
                <el-skeleton-item />
                <el-skeleton-item />
            </template>
            <template #default>
                <div class="title-box" v-if="detailData">
                    <div class="left-title">
                        <span class="title">{{ detailData.integratorName }}</span>
                        <span>
                            已集成
                            <span class="number">{{
                                !detailData.integrationProductCount && detailData.integrationProductCount != 0
                                    ? '--'
                                    : detailData.integrationProductCount
                            }}</span>
                            个产品
                        </span>
                    </div>
                    <div class="right-title">
                        <el-button @click="onGoPage">返回</el-button>
                    </div>
                </div>
            </template>
        </el-skeleton>
    </div>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router';

const props = defineProps<{
    detailData?: Record<string, any>;
}>();
const router = useRouter();
const loading = ref(true);

const onGoPage = () => {
    router.push('/message/integration/list');
};

watch(
    () => props.detailData,
    newValue => {
        if (newValue) loading.value = false;
    },
    { immediate: true }
);
</script>
<style scoped lang="scss">
.title-wrapper {
    .el-skeleton {
        display: flex;
        .el-skeleton__item {
            width: 20%;
            height: 32px;
        }
        .el-skeleton__item + .el-skeleton__item {
            margin-left: 10px;
            width: 60px;
        }
    }
    .title-box {
        display: flex;
        justify-content: space-between;
        height: 32px;
        align-items: center;
        .left-title {
            display: flex;
            align-items: center;
            .title {
                font-size: 18px;
                font-weight: 600;
            }
            .number {
                color: #409eff;
            }
            > span + span {
                margin-left: 10px;
            }
        }
    }
}
</style>
